<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>抱团商家</title>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no,minimal-ui,viewport-fit=cover"/>
    <meta name="keywords" content="抱团">
    <meta name="description" content="抱团">
    <script type="text/javascript" src="../common/js/base.js" charset="UTF-8"></script>
    <link rel="stylesheet" type="text/css" href="../common/css/elementui.min.css">
    <link rel="stylesheet" type="text/css" href="../common/css/animate.min.css">
    <link rel="stylesheet" type="text/css" href="../common/css/nanoscroller.css">
    <link rel="stylesheet" type="text/css" href="../common/css/swiper-bundle.min.css">
    <link rel="stylesheet" type="text/css" href="../common/css/base.css">
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <script type='text/javascript' src="../common/js/jquery.min.js" charset="UTF-8"></script>
    <script type='text/javascript' src="../common/js/jquery.easing.js" charset="UTF-8"></script>
    <script type='text/javascript' src="../common/js/html2canvas.min.js" charset="UTF-8"></script>
    <script type="text/javascript" src="../common/js/layer/layer.js" charset="UTF-8"></script>
    <script type="text/javascript" src="../common/js/wow.js" charset="UTF-8"></script>
    <script type="text/javascript" src="../common/js/vue.js" charset="UTF-8"></script>
    <script type="text/javascript" src="../common/js/vue-resource.js" charset="UTF-8"></script>
    <script type="text/javascript" src="../common/js/axios.min.js" charset="UTF-8"></script>
    <script type='text/javascript' src="../common/js/elementui.min.js" charset="UTF-8"></script>
    <script type='text/javascript' src="../common/js/jquery.nanoscroller.js" charset="UTF-8"></script>
    <script type='text/javascript' src="../common/js/swiper.animate.min.js" charset="UTF-8"></script>
    <script type='text/javascript' src="../common/js/swiper-bundle.min.js" charset="UTF-8"></script>
    <script type='text/javascript' src="../common/js/helper.js?1=1" charset="UTF-8"></script>
    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js" charset="UTF-8"></script>
</head>
<body>
<div class="wrapperbox shophomepage hasmenu" id="app">
    <div class="top">
        <div class="head" v-on:click="my">
            <img class="headimg" :src="merchant.logo_image_url">
        </div>
        <div class="myname" v-on:click="my">{{merchant.name}}</div>
        <div class="exit">
            <img class="back" src="images/back.png">
            <span class="exitright" v-on:click="logout">退出</span>
        </div>
        <div class="button_warp">
            <div class="button" v-on:click="hexiaoScan">
                <img class="scan" src="images/scan2.png">
                <span class="btn">扫一扫核销</span>
            </div>
            <div class="button" style="float:right" v-on:click="hexiaoInput">
                <img class="scan" src="images/barcode2.png">
                <span class="btn">电子码核销</span>
            </div>
        </div>
    </div>
    <div class="message">
        <div class="tittle">
            <div class="today">今日收益</div>
            <div class="flex">
                <span class="todaynum">{{summary.daily_profit}}</span>
                <div class="allmessage" v-on:click="bankcard">
                    <span v-if="has_account">完善提现信息</span>
                    <span style="color: red" v-else>提交提现信息</span>
                    <img src="images/right2.png">
                </div>
            </div>
        </div>
        <div class="list">
            <div class="row">
                <div class="item item1">
                    <span>总收益：</span>
                    <h3>{{summary.total_profit || 0}}</h3>
                </div>
                <div class="item item2">
                    <span>暂存收益：</span>
                    <h3>{{summary.temp_profit || 0}}</h3>
                </div>
            </div>
            <div class="row">
                <div class="item item1">
                    <span>已结算收益：</span>
                    <h3>{{summary.settled_profit || 0}}</h3>
                </div>
                <div class="item item2">
                    <span>可结算收益：</span>
                    <h3>{{summary.confirmed_profit || 0}}</h3>
                </div>
            </div>
        </div>
    </div>
    <div class="order" v-on:click="order">
        <div class="oitem">我的订单</div>
        <div class="oitem">
            <span>销售数量：</span>
            <h3>{{summary.total_count || 0}}</h3>
        </div>
        <div class="oitem">
            <span>已核销数量：</span>
            <h3>{{summary.consumed_count || 0}}</h3>
        </div>
        <div class="oitem">
            <span>未核销数量：</span>
            <h3>{{summary.pending_count || 0}}</h3>
        </div>
    </div>

</div>

<div class="footer">
    <div class="item">
        <a href="shophome.html">
            <img class="itemimg" src="images/nav_home_active.png">
            <p class="itemname">首页</p>
        </a>
    </div>
    <div class="item">
        <a href="activity.html">
            <img class="itemimg" src="images/nav_activity.png">
            <p class="itemname">活动及销售</p>
        </a>
    </div>
    <div class="item">
        <a href="order.html">
            <img class="itemimg" src="images/nav_order.png">
            <p class="itemname">订单</p>
        </a>
    </div>
    <div class="item">
        <a href="my.html">
            <img class="itemimg" src="images/nav_my.png">
            <p class="itemname">我的</p>
        </a>
    </div>
</div>

</body>
<script>
  $(function () {
    new Vue({
      el: '#app',
      data() {
        return {
          merchant: {},
          summary: {},
          has_account: false,
        }
      },
      mounted() {
        this.init()
        this.loadSummary()
      },
      created() {
        this.merchant = JSON.parse(localStorage.getItem('merchant'))
        merchant_get('withdraw_account').then(res => {
          if (res.name) {
            this.has_account = true;
          }
        })
      },
      methods: {
        init: function () {
          common_get('jssdk_params?url=' + encodeURIComponent(window.location.href)).then(res => {
            wx.config({
              debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
              appId: res.appId, // 必填，公众号的唯一标识
              timestamp: res.timestamp, // 必填，生成签名的时间戳
              nonceStr: res.nonceStr, // 必填，生成签名的随机串
              signature: res.signature,// 必填，签名
              jsApiList: ['scanQRCode'] // 必填，需要使用的JS接口列表
            });
          })
        },
        loadSummary: function () {
          merchant_get('summary').then(res => {
            this.summary = res
          })
        },
        my: function () {
          window.location.href = 'my.html'
        },
        logout: function () {
          localStorage.removeItem('merchant_token')
          window.location.href = 'index.html'
        },
        bankcard: function () {
          if (this.has_account) {
            window.location.href = 'bankcard.html'
          } else {
            window.location.href = 'changebankcard.html'
          }
        },
        hexiaoScan: function () {
          wx.ready(function () {
            wx.scanQRCode({
              needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
              scanType: ["qrCode"], // 可以指定扫二维码还是一维码，默认二者都有
              success: function (res) {
                window.location.href = 'hexiao.html?code=' + res.resultStr
              }
            });
          })
        },
        hexiaoInput: function () {
          window.location.href = 'hexiao.html'
        },
        order: function () {
          window.location.href = 'order.html'
        }
      }
    });
  })
</script>
</html>
